#include <stdio.h>
#include <string.h>
#define N 100000
int main()
{
	int a[N], i, n, num, k, x[N];
	memset (a,0,sizeof(a));
	
	scanf ("%d",&n);
	for ( i=0 ; i<n ; i++) {
		scanf ("%d",&num);
		a[ num ]++;
	}
	
	scanf ("%d",&k);
	
	for ( i=0 ; i<k ; i++ )
		scanf ("%d",&x[i]);
	//printf("%d\n",k);
	
	for ( i=0 ; i<k ; i++ ) {
		printf("%d",a[ x[i] ]);
		if(i<k-1)
			printf(" ");
	}
	printf("\n");
	return 0;
}
